package com.gaga.console.core.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.gaga.common.exception.BusException;
import com.gaga.console.base.service.impl.SuperServiceImpl;
import com.gaga.console.core.entity.BvConfig;
import com.gaga.console.core.entity.dto.ConfigDto;
import com.gaga.console.core.mapper.BvConfigMapper;
import com.gaga.console.core.service.BvConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 用户信息表 服务实现类
 * </p>
 *
 * @author liujia
 * @since 2025-03-27
 */
@Slf4j
@Service("bvConfigService")
public class BvConfigServiceImpl extends SuperServiceImpl<BvConfigMapper, BvConfig> implements BvConfigService {

    @Override
    public ConfigDto getConfig() {
        BvConfig bvConfig = getById(0L);
        if (bvConfig == null) {
            throw new BusException("请先维护系统配置");
        }

        ConfigDto configDto = JSONObject.parseObject(bvConfig.getConfig(), ConfigDto.class);
        if (configDto == null) {
            throw new BusException("请先维护系统配置");
        }
        return configDto;
    }

    @Override
    public String getSelectDeviceName() {
        ConfigDto config = getConfig();
        return config.getOutMediaDevice();
    }

    @Override
    public List<String> getSelectModelNameList() {
        ConfigDto config = getConfig();
        List<String> modelList = new ArrayList<>();
        modelList.add(config.getModelSetting().getAnchor());
        modelList.add(config.getModelSetting().getAssistant());

        return modelList;
    }
}
